package com.company.cloud.art.modules.bus.consumer;

import com.alibaba.fastjson.JSON;
import com.company.cloud.art.modules.mgr.service.ActArtistMgrService;
import com.company.cloud.common.constant.ConfigConstants;
import com.company.cloud.common.mq.redis.client.consumer.MQSaasResult;
import com.company.cloud.common.mq.redis.client.consumer.annotation.MQRedisConsumer;
import com.company.cloud.common.utils.StrSplitUtils;
import com.company.common.server.config.mq.constant.MQTopicKeys;
import com.company.common.server.config.mq.models.MQPrdModel;
import com.company.common.server.constant.CloudConstant;
import lombok.extern.log4j.Log4j2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.jms.annotation.JmsListener;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;

import java.util.Set;


@Log4j2
@ConditionalOnProperty(value = ConfigConstants.CONFIG_Active_MQ_ENABLED, havingValue = "true")
@Service
public class ArtPrdActiveComsumer {

    @Autowired
    private ActArtistMgrService actArtistMgrService;



    @JmsListener(destination = MQTopicKeys.MQ_PRD_Change_Topic ,containerFactory = "topicListener")
    public void consume(String message){
//        try {
//            MQPrdModel prdModel= JSON.parseObject(message,MQPrdModel.class);
//            if(prdModel!=null){
//                Set<String> artistNos= StrSplitUtils.parse2set(prdModel.getBizValue4(),String.class);
//                if(!CollectionUtils.isEmpty(artistNos)){
//                    if(CloudConstant.EntityOpWayEnum.ENTITY_ADD.getCode().equals(prdModel.getOpWay())){
//                        actArtistMgrService.artistAddPrd(artistNos,prdModel.getProductNo());
//                    }
//                    if(CloudConstant.EntityOpWayEnum.ENTITY_EDIT.getCode().equals(prdModel.getOpWay())){
//                        actArtistMgrService.artistEditPrd(artistNos,prdModel.getProductNo());
//                    }
//                    if(CloudConstant.EntityOpWayEnum.ENTITY_DEL.getCode().equals(prdModel.getOpWay())){
//                        actArtistMgrService.artistDelPrd(artistNos,prdModel.getProductNo());
//                    }
//                }
//            }
//        }catch (Exception e){
//            log.debug("+++++ ArtPrdComsumer Error : {}",e.getMessage());
//        }
    }



}
